package com.woniu.user.service.Imp;

import com.woniu.common.CustomException.UserException;
import com.woniu.common.pojo.Type;
import com.woniu.user.mapper.TypeMapper;
import com.woniu.user.service.TypeService;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TypeServiceImp implements TypeService {
    @Resource
    private TypeMapper typeMapper;
    @Resource
    private RedisTemplate redisTemplate;

    @Override
    public List<Type> getTypeList() {
        return  typeMapper.getTypeList();
//        List<Type> typeList = (List<Type>) redisTemplate.opsForValue().get("types");
//        if (typeList == null) {
//            List<Type> typeList1 = typeMapper.getTypeList();
//            if (typeList1 != null) {
//                redisTemplate.opsForValue().set("types", typeList1);
//                return typeList1;
//            }
//            throw new UserException("不好意思,类型空了");
//        }
//        return typeList;
    }
}
